package com.mobi.Survey.controller;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.mobi.Survey.model.AbstractTable;
import com.mobi.Survey.model.AggregateResultTable;

/**
 * 
 * <b>Author:</b> Yahya Arshad
 * <p>
 * <b>Company:</b> Mobi Media Soft
 * <p>
 * <b> Website:</b> www.mobimediasoft.com
 * <p>
 * AggregateResultPojo.java
 */
public class AggregateResultPojo extends Pojo
{
	private long id;
	private int sequanceNo;
	private int surveyId;
	private byte ctrlType;
	private String title;
	private List<String> ratings = new ArrayList<String>();
	private List<Double> counts = new ArrayList<Double>();;
	private String surveyKey;

	public String getSurveyKey()
	{
		if (surveyKey == null)
			return "";
		return surveyKey;
	}

	public AggregateResultPojo setSurveyKey(String key)
	{
		surveyKey = key;
		return this;
	}

	public long getId()
	{
		return id;
	}

	public int getSurveyId()
	{
		return surveyId;
	}

	public byte getCtrlType()
	{
		return ctrlType;
	}

	public AggregateResultPojo setId(long id)
	{
		this.id = id;
		return this;
	}

	public AggregateResultPojo setSurveyId(int surId)
	{
		surveyId = surId;
		return this;
	}

	public AggregateResultPojo setCtrlType(byte ctrlType)
	{
		this.ctrlType = ctrlType;
		return this;
	}

	public int getSequanceNo()
	{
		return sequanceNo;
	}

	public AggregateResultPojo setSequanceNo(int sequanceNo)
	{
		this.sequanceNo = sequanceNo;
		return this;
	}

	public static final boolean delete(Context ctx, long surveyId)
	{
		AbstractTable at = new AggregateResultTable(ctx);
		boolean isDelete = at.deleteRow(surveyId);

		at.closeDB();
		return isDelete;
	}

	public List<String> getRatings()
	{
		return ratings;
	}

	public List<Double> getCounts()
	{
		return counts;
	}

	public AggregateResultPojo setRatings(List<String> ratings)
	{
		this.ratings = ratings;
		return this;
	}

	public AggregateResultPojo setCounts(List<Double> counts)
	{
		this.counts = counts;
		return this;
	}

	public String getTitle()
	{
		return title;
	}

	public AggregateResultPojo setTitle(String title)
	{
		this.title = title;
		return this;
	}

	public static boolean isNew(Context ctx, String sKey)
	{
		AggregateResultTable art = new AggregateResultTable(ctx);
		int ret = art.isNew(sKey);

		art.closeDB();
		return ret <= 0;
	}

}
